  jQuery(document).ready(function($) {
	
	var typewidthval = jQuery.cookie("ts_cookie_typewidthval");
	if(typewidthval=="transparent"){
		var lightselected =  "";
		var darkselected = "";
		var minimalselected = "";
		var transparentselected = 'selected="selected"';
	}else if (typewidthval=="dark"){
		var lightselected = "";
		var darkselected = 'selected="selected"';
		var minimalselected = "";
		var transparentselected = "";
	}else if (typewidthval=="minimal"){
		var lightselected = "";
		var darkselected = "";
		var minimalselected = 'selected="selected"';
		var transparentselected = "";
	}else{
		var lightselected = 'selected="selected"';
		var darkselected = "";
		var minimalselected = "";
		var transparentselected = '';
	}
	
	var styleswitcherstr = ' \
	<div id="style-switcher"> \
	<form id="style-switcher-form">\
	  <div class="switchercontainer"> \
		  <span>Type Layout</span> \
		  <div id="typewidthcontainer"> \
		  	<select id="typewidth" name="typewidth"> \
				<option value="light" '+lightselected+'>Light</option> \
				<option value="dark" '+darkselected+'>Dark</option> \
				<option value="minimal" '+minimalselected+'>Minimal</option> \
				<option value="transparent" '+transparentselected+'>Transparent</option> \
			</select> \
		  </div> \
		  <div class="clear"></div> \
	  </div> \
	  <div class="switchercontainer"> \
		  <a href="#" id="switcher-reset">Reset</a> \
		  <div class="clear"></div> \
	  </div> \
	</form>\
	</div> \
	';
	
	jQuery("body").prepend( styleswitcherstr );
	
	jQuery('#typewidth').change(function(e){
		var typewidthval = jQuery(this).val();
		jQuery("#skinscss").attr("href","themes/Cleanex/views/layouts/styles/skins/"+typewidthval+".css");

		if(typewidthval=="light"){
			
			var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/light/bg-body.png)';
			jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#f5862d");
			jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#ffffff");
			jQuery("h6:not(.clean)").css("color","#6e6e6e");
			jQuery("#sidebar li.newslist .title a").css("color","#6e6e6e");
			
		} else if(typewidthval=="dark"){
			var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/dark/bg-body.png)';
			jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#cd6d4c");
			jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#a3a3a3");
			jQuery("h6:not(.clean)").css("color","#6e6e6e");
			jQuery("#sidebar li.newslist .title a").css("color","#6b6b6b");
			
		} else if(typewidthval=="minimal"){
			var bodybgcolor = "fff";
			var backgroundUrl = 'none';
			jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#f5862d");
			jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#ffffff");
			jQuery("h6:not(.clean)").css("color","#6e6e6e");
			jQuery("#sidebar li.newslist .title a").css("color","#6e6e6e");
			
		} else {
			var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/transparent/bg-body.jpg)';
			jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#7e7e7e");
			jQuery("#slideshow .slider-desc, .header-desc h4, #sidebar li.newslist .title a").css("color","#cd6d4c");
			jQuery("h6:not(.clean)").css("color","#6e6e6e");
			jQuery("#sidebar li.newslist .title a").css("color","#cd6d4c");
			
		}
		
		jQuery('body').css({
			"background-color": '#' + bodybgcolor,
			backgroundImage: backgroundUrl,
			backgroundRepeat: "repeat"
		});     
		jQuery.cookie("ts_cookie_bodybgcolor", bodybgcolor);
		jQuery.cookie("ts_cookie_bgimage",backgroundUrl);
		jQuery.cookie("ts_cookie_typewidthval", typewidthval);
		
		Cufon.refresh();
		
	});
    
	
	
	/*************** END COLOR PICKER ******************/
	
	
  var headercolor		= jQuery.cookie("ts_cookie_headercolor");
  var contentcolor		= jQuery.cookie("ts_cookie_contentcolor");
  var linkcolor			= jQuery.cookie("ts_cookie_linkcolor");
  var bodycolor			= jQuery.cookie("ts_cookie_bodycolor");
  var bodybgcolor		= jQuery.cookie("ts_cookie_bodybgcolor");
  var background 		= jQuery.cookie("ts_cookie_bgimage");
  var typewidthval		= jQuery.cookie("ts_cookie_typewidthval");
  
  
  if(bodycolor){
	jQuery("body").css({
		"color" : "#"+bodycolor
	});  
  }
  
  
  if(bodybgcolor){
  	jQuery('body').css({
		"background-color": '#'+bodybgcolor
	});
  }

  if (background) {
      jQuery('body').css({
        backgroundImage: background,
        backgroundRepeat: "repeat"
      });
  } 
  
  if (typewidthval) {
      jQuery("#skinscss").attr("href","themes/Cleanex/views/layouts/styles/skins/"+typewidthval+".css");
  } 
  
  	if(typewidthval=="transparent"){
		var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/light/bg-body.png)';
		jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#7e7e7e");
		jQuery("#slideshow .slider-desc, .header-desc h4, #sidebar li.newslist .title a").css("color","#cd6d4c");
		jQuery("h6:not(.clean)").css("color","#6e6e6e");
		jQuery("#sidebar li.newslist .title a").css("color","#cd6d4c");
		
	} else if(typewidthval=="dark"){
		var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/dark/bg-body.png)';
		jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#cd6d4c");
		jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#a3a3a3");
		jQuery("h6:not(.clean)").css("color","#6e6e6e");
		jQuery("#sidebar li.newslist .title a").css("color","#6b6b6b");
		
	} else if(typewidthval=="minimal"){
		var bodybgcolor = "fff";
		var backgroundUrl = 'none';
		jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#f5862d");
		jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#ffffff");
		jQuery("h6:not(.clean)").css("color","#6e6e6e");
		jQuery("#sidebar li.newslist .title a").css("color","#6e6e6e");
		
	} else {
		var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/transparent/bg-body.jpg)';
		jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#f5862d");
		jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#ffffff");
		jQuery("h6:not(.clean)").css("color","#6e6e6e");
		jQuery("#sidebar li.newslist .title a").css("color","#6e6e6e");
		
		
	}
  
  Cufon.refresh();
  
  jQuery("#switcher-reset").click(function(){
  		
	/**	var bodycolor = "8c8c8c";
		jQuery('body').css({
			"color": '#' + bodycolor
		});     
		jQuery.cookie("ts_cookie_bodycolor", bodycolor);
		
		
		var bodybgcolor = "eaeaea";
		jQuery('body').css({
			"background-color": '#' + bodybgcolor
		});     
		jQuery.cookie("ts_cookie_bodybgcolor", bodybgcolor);*/
		
		
		var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/light/bg-body.png)';
		jQuery('body').css({
		  	backgroundImage: backgroundUrl,
		  	backgroundRepeat: "repeat"
	  	});
		jQuery.cookie("ts_cookie_bgimage",backgroundUrl);
		
		var typewidthval = "light";
		jQuery("#skinscss").attr("href","themes/Cleanex/views/layouts/styles/skins/"+typewidthval+".css");
		
		if(typewidthval=="light"){
			var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/light/bg-body.png)';
			jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#f5862d");
			jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#ffffff");
			jQuery("h6:not(.clean)").css("color","#6e6e6e");
			jQuery("#sidebar li.newslist .title a").css("color","#6e6e6e");
			
		} else if(typewidthval=="dark"){
			var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/dark/bg-body.png)';
			jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#cd6d4c");
			jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#a3a3a3");
			jQuery("h6:not(.clean)").css("color","#6e6e6e");
			jQuery("#sidebar li.newslist .title a").css("color","#6b6b6b");
			
		} else if(typewidthval=="minimal"){
			var bodybgcolor = "fff";
			var backgroundUrl = 'none';
			jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#f5862d");
			jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#ffffff");
			jQuery("h6:not(.clean)").css("color","#6e6e6e");
			jQuery("#sidebar li.newslist .title a").css("color","#6e6e6e");
			
		} else {
			var backgroundUrl = 'url(themes/Cleanex/views/layouts/styles/skins/transparent/bg-body.jpg)';
			jQuery("h1, h2, h3, h4, h5, #slideshow h1, .posttitle a").css("color","#7e7e7e");
			jQuery("#slideshow .slider-desc, .header-desc h4").css("color","#cd6d4c");
			jQuery("h6:not(.clean)").css("color","#6e6e6e");
			jQuery("#sidebar li.newslist .title a").css("color","#cd6d4c");
			
		}
		
		
		jQuery.cookie("ts_cookie_typewidthval",typewidthval);
		
		jQuery("#typewidth").val("light");
		 
		
		Cufon.refresh();
  });
         
});